import { appConfig } from "@/config"
export const cache = {
	get: {
		token: () => uni.getStorageSync(appConfig.tokenKey),
		settleIn: () => uni.getStorageSync(appConfig.settleInKey),
		pushCid: () => uni.getStorageSync(appConfig.pushCidKey),
		staging: () => uni.getStorageSync(appConfig.stagingKey),
		repair: () => uni.getStorageSync(appConfig.repairKey),
		stagingExpire: () => uni.getStorageSync(appConfig.stagingExpireKey),
		repairExpire: () => uni.getStorageSync(appConfig.repairExpireKey),
	},
	set: {
		token: (value) => uni.setStorageSync(appConfig.tokenKey, value),
		settleIn: (value) => uni.setStorageSync(appConfig.settleInKey, value),
		pushCid: (value) => uni.setStorageSync(appConfig.pushCidKey, value),
		staging: (value) => uni.setStorageSync(appConfig.stagingKey, value),
		repair: (value) => uni.setStorageSync(appConfig.repairKey, value),
		stagingExpire: (value) => uni.setStorageSync(appConfig.stagingExpireKey, value),
		repairExpire: (value) => uni.setStorageSync(appConfig.repairExpireKey, value),
	},
	remove: {
		token: () => uni.removeStorageSync(appConfig.tokenKey),
		settleIn: () => uni.removeStorageSync(appConfig.settleInKey),
		pushCid: () => uni.removeStorageSync(appConfig.pushCidKey),
		staging: () => uni.removeStorageSync(appConfig.stagingKey),
		repair: () => uni.removeStorageSync(appConfig.repairKey),
		stagingExpire: () => uni.removeStorageSync(appConfig.stagingExpireKey),
		repairExpire: () => uni.removeStorageSync(appConfig.repairExpireKey),
	},
	clearAll(){
		return new Promise((resolve, reject) => {
			uni.clearStorageSync()
			resolve(true)
		})
	}
}